package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Setmeal;
import com.itheima.pojo.SetmealDEV;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 新增体检套餐
     */
    void list(SetmealDEV setmealDEV);

    /**
     * 分页查询套餐表
     * @param setmeal
     * @return
     */
    Page<Setmeal> listpage(Setmeal setmeal);

    /**
     * 根据id查询套餐表
     * @param id
     * @return
     */
    @Select("select * from t_setmeal where id=#{id}")
    CheckItem readsetmeal(Integer id);

    /**
     * 删除套餐
     * @param id
     */
    @Delete("delete from t_setmeal where id=#{id}")
    void delect(Integer id);

    /**
     * 修改套餐
     * @param setmeal
     */
    void update(Setmeal setmeal);

    /**
     * 生成套餐列表
     * @return
     */
    @Select("select * from czjk_name.t_setmeal")
    List <Setmeal> findAll();

    /**
     *生成套餐详情
     * @param id
     * @return
     */
    @Select("select * from ")
    List <Setmeal> findbyid(Integer id);
    /**
     * 根据套餐id查询关联检查组
     * @param id
     */
    @Select("select * from t_setmeal where id= #{id}")
    Setmeal list1(Integer id);
    /**
     * 根据检查组id查询检查项
     * @param id1
     * @return
     */
    @Select("select b.id, b.code, b.name, b.sex, b.age, b.price, b.type, b.attention, b.remark " +
            "from t_checkgroup a,t_checkitem b,t_checkgroup_checkitem c  where a.id=c.checkgroup_id and b.id =c.checkitem_id and a.id=#{id}")
    List<CheckItem> list2(Integer id1);

    /**
     * 关联表查询
     * @param id
     * @return
     */
    @Select("select  c.id, c.code, c.name, c.helpCode, c.sex, c.remark, c.attention from " +
            "t_setmeal a,t_setmeal_checkgroup b,t_checkgroup c  where a.id=b.setmeal_id and b.checkgroup_id =c.id and a.id=#{id}")

    List<CheckGroup> list3(Integer id);
}
